package com.starlink.controller;

import com.starlink.common.annotation.client.jd.JdOperationRequest;
import com.starlink.common.annotation.client.jd.JdOperationResponse;
import com.starlink.service.JDTraceCallBackService;
import com.starlink.utils.FastJsonUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: zhouyuhang01
 * @Date: 2024/5/21 15:21
 * @Description: JDTraceCallBackController
 * @Version 1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/jd/free")
@Api(value = "京东物流模块", tags = {"京东物流模块"})
public class JDTraceCallBackController {

    @Autowired
    private JDTraceCallBackService jdTraceCallBackService;

    @ApiOperation(value = "京东物流轨迹推送通知", httpMethod = "POST")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "success")})
    @PostMapping("/trace_msg/push")
    public JdOperationResponse traceMsgPush(@RequestBody JdOperationRequest req) {
        log.info("JdOperation 京东物流轨迹推送通知: {}", FastJsonUtils.toJSONString(req));
        return jdTraceCallBackService.traceMsgPush(req);
    }
}
